package cn.itcast.order.service.impl;

import cn.itcast.order.mapper.OrderInfoMapper;
import cn.itcast.order.model.OrderInfo;
import cn.itcast.order.service.IOrderInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 订单列表 服务实现类
 * </p>
 *
 * @author xhx
 * @since 2023-04-02
 */
@Service
public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements IOrderInfoService {
    @Resource
    private OrderInfoMapper orderInfoMapper;

    @Override
    public int add(OrderInfo orderInfo) {
        return orderInfoMapper.insert(orderInfo);
    }

    @Override
    public List<OrderInfo> listOrder() {
        return orderInfoMapper.selectList(null);
    }

    @Override
    public List<OrderInfo> findOrderByUserId(Long userId) {
        Map<String, Object> columnMap = new HashMap<>();
        columnMap.put("user_id", userId);

        return orderInfoMapper.selectByMap(columnMap);
    }
}
